﻿@model SettingsViewModel
@{
	ViewBag.Title = @Strings.Settings;
}
<style type="text/css">
	#general .editor-label { width: 275px; }
	#posts .editor-label, #email .editor-label { width: 250px; }
	form { font-size: .9em; }
	#buttons { padding-top: 10px; }	
</style>
<script type="text/javascript">
	$(document).ready(function () {
		$("#adminTabs").tabs();
		toggleSmtpSettings();

		$("#UseSmtpAuthentication").click(function () {
			toggleSmtpSettings();
		});

		var loader = $("#loader");
		loader.hide();

		new AjaxUpload($("#uploadButton"), {
			autoSubmit: true,
			dataType: 'json',
			name: 'file',
			action: '/Admin/BlogMLImport',
			onSubmit: function (file, ext) {
				loader.show();
			},
			onComplete: function (file, response) {
				eval("var result = " + response + ";");
				loader.hide();
				alert(result.Message);                
			}
		});

	});

	function toggleSmtpSettings() {
		var checked = $("#UseSmtpAuthentication").is(":checked");
		if (!checked) {
			$("#Settings_SmtpUserName").attr("disabled", true);
			$("#Settings_SmtpPassword").attr("disabled", true);
		}
		else {
			$("#Settings_SmtpUserName").removeAttr("disabled");
			$("#Settings_SmtpPassword").removeAttr("disabled");
		}
	}
</script>
@Html.ValidationSummary(true)
@using (Html.BeginForm()) {	
	
	<div id="adminTabs">
		<ul>
			<li><a href="#general">@Strings.Settings_General</a></li>
			<li><a href="#posts">@Strings.Settings_Posts</a></li>
			<li><a href="#email">@Strings.Settings_Email</a></li>
			<li><a href="#importBlog">@Strings.Settings_Import</a></li>
		</ul>
		<div id="general">
			<div class="editor-label">
				<label for="Settings_Name">@Strings.Settings_Name</label>
			</div>
			<div class="editor-field">
				@Html.TextBoxFor(m => m.Settings.Name)
				@Html.ValidationMessageFor(m => m.Settings.Name)
			</div>
			<div class="editor-label">
				<label>@Strings.Settings_Description</label>
			</div>
			<div class="editor-field">
				@Html.TextBoxFor(m => m.Settings.Description, new { size = "50" })
				@Html.ValidationMessageFor(m => m.Settings.Description)
			</div>
			<div class="editor-label">
				<label>@Strings.Settings_HostHeaderValues</label>
				<div style="padding-top: 5px; margin-right: 5px;">
					<em>@Html.Raw(Strings.Settings_HostHeaderValuesDescription)</em>
				</div>
			</div>
			<div class="editor-field">
				@Html.TextAreaFor(m => m.Settings.HostHeaderValues, new { rows = 5, cols = 50 })
			</div>
			<div class="editor-label">
				<label>@Strings.Settings_MetaKeywords</label>
			</div>
			<div class="editor-field">
				@Html.TextBoxFor(m => m.Settings.MetaKeywords, new { size = "50" })
			</div>
			<div class="editor-label">
				<label for="Settings_MetaDescription">@Strings.Settings_MetaDescription</label>
			</div>
			<div class="editor-field">
				@Html.TextBoxFor(m => m.Settings.MetaDescription, new { size = "50" })
			</div>
			<div class="editor-label">
				<div>
					<label>@Strings.Settings_TrackingScript</label></div>
				<div style="padding-top: 5px; margin-right: 5px;">
					<em>@Html.Raw(Strings.Settings_TrackingScriptDescription)</em>
				</div>
			</div>
			<div class="editor-field">
				@Html.TextAreaFor(m => m.Settings.TrackingScript, new { rows = 8, cols = 50 })
			</div>
			<div class="editor-label">
				<label for="Settings_Theme">@Strings.Settings_Theme</label>
			</div>
			<div class="editor-field">
				@Html.DropDownListFor(m => m.Settings.Theme, Model.Themes)
			</div>
			<div class="editor-label">
				<label for="Settings_DateFormat">@Strings.Settings_DateFormat</label>
			</div>
			<div class="editor-field">
				@Html.TextBoxFor(m => m.Settings.DateFormat)
			</div>
			<div class="editor-label">
				<label for="Settings_FeedFormat">@Strings.Settings_FeedFormat</label>
			</div>
			<div class="editor-field">
				@Html.DropDownListFor(m => m.Settings.FeedFormat, Model.FeedFormats)
			</div>
			<div class="editor-label">
				<label for="Settings_AllowOpenRegistration">@Strings.Settings_AllowOpenRegistration</label>
			</div>
			<div class="editor-field">
				@Html.CheckBoxFor(m => m.Settings.AllowOpenRegistration)
			</div>
		</div>
		<div id="posts">
			<div class="editor-label">
				<label for="Settings_PostsPerPage">@Strings.Settings_PostsPerPage</label>
			</div>
			<div class="editor-field">
				@Html.TextBoxFor(m => m.Settings.PostsPerPage, new { size = 3 })
			</div>
			<div class="editor-label">
				<label for="Settings_SocialNetworkingSupport">@Strings.Settings_SocialNetworkingSupport</label>
			</div>
			<div class="editor-field">
				@Html.CheckBoxFor(m => m.Settings.SocialNetworkingSupport)
			</div>
			<div class="editor-label">
				<label for="Settings_AllowAnonymousRatings">@Strings.Settings_AllowAnonymousRatings</label>
			</div>
			<div class="editor-field">
				@Html.CheckBoxFor(m => m.Settings.AllowAnonymousRatings)
			</div>
			<div class="editor-label">
				<label for="Settings_AreCommentsEnabled">@Strings.Settings_AreCommentsEnabled</label>
			</div>
			<div class="editor-field">
				@Html.CheckBoxFor(m => m.Settings.AreCommentsEnabled)
			</div>
			<div class="editor-label">
				<label for="Settings_AllowAnonymousComments">@Strings.Settings_AllowAnonymousComments</label>
			</div>
			<div class="editor-field">
				@Html.CheckBoxFor(m => m.Settings.AllowAnonymousComments)
			</div>
			<div class="editor-label">
				<label for="Settings_ModerateComments">@Strings.Settings_ModerateComments</label>
			</div>
			<div class="editor-field">
				@Html.CheckBoxFor(m => m.Settings.ModerateComments)
			</div>
			<div class="editor-label">
				<label for="Settings_TrackPostVisits">@Strings.Settings_TrackPostVisits</label>
			</div>
			<div class="editor-field">
				@Html.CheckBoxFor(m => m.Settings.TrackPostVisits)
			</div>
		</div>
		<div id="email">
			<div class="editor-label">
				<label for="SmtpServer">@Strings.Settings_SmtpServer</label>
			</div>
			<div class="editor-field">
				@Html.TextBoxFor(m => m.Settings.SmtpServer)
			</div>
			<div class="editor-label">
				<label for="SmtpPort">@Strings.Settings_SmtpPort</label>
			</div>
			<div class="editor-field">
				@Html.TextBoxFor(m => m.Settings.SmtpPort, new { size = 5 })
			</div>
			<div class="editor-label">
				<label for="Settings_SmtpEnableSsl">@Strings.Settings_SmtpEnableSsl</label>
			</div>
			<div class="editor-field">
				@Html.CheckBox("Settings_SmtpEnableSsl", @Model.Settings.SmtpEnableSsl ?? false)
			</div>
			<div class="editor-label">
				<label for="UseSmtpAuthentication">@Strings.Settings_EnableSmtpAuthentication</label>
			</div>
			<div class="editor-field">
				<input id="UseSmtpAuthentication" name="UseSmtpAuthentication" type="checkbox" (@Model.UseSmtpAuthentication ? "checked='checked'" : "") >
			</div>
			<div class="editor-label">
				<label for="Settings_SmtpUserName">@Strings.Settings_SmtpUsername</label>
			</div>
			<div class="editor-field">
				@Html.TextBoxFor(x => x.Settings.SmtpUserName)
			</div>
			<div class="editor-label">
				<label for="Settings_SmtpPassword">@Strings.Settings_SmtpPassword</label>
			</div>
			<div class="editor-field">
				@Html.TextBoxFor(x => x.Settings.SmtpPassword)
			</div>
			<br />
			<br />
			<div class="editor-label">
				<label for="Settings_CommentEmailSubjectPrefix">@Strings.Settings_CommentEmailSubjectPrefix</label>
			</div>
			<div class="editor-field">
				@Html.TextBoxFor(m => m.Settings.ContactEmailSubjectPrefix, new { size = 40 })
			</div>
		</div>
		<div id="importBlog">
			<div id="loader">
				<img src="../../Content/Images/ajax_upload.gif" /><br />
				Please wait, importing...
			</div>
			<div class="file_inputs">
				@Strings.Settings_BlogMLDescription<br />
				<br />
				<input id="uploadButton" type="button" value="@Strings.Blog_Import" />
			</div>            
			<br />
			<a href="/blogml.axd">@Strings.Blog_Export</a>
		</div>
	</div>					
	<div id="buttons">
		<input type="submit" value='@Strings.Save'/>
	</div>																	        
}
